package com.stark.friendrequest;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class EnterDetails extends Activity {

	private Button submitButton;
	private SharedPreferences prefs;
	private EditText nameText, numText;
	private String name, num;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.enter_details);
		
		nameText = (EditText)findViewById(R.id.name_text);
		numText = (EditText)findViewById(R.id.num_text);
		
		name = nameText.getText().toString();
		System.out.println(name + "***");
		num = numText.getText().toString();
		System.out.println(num + "**");
		
		prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
		
		submitButton = (Button)findViewById(R.id.submit_button);
		submitButton.setOnClickListener(new Button.OnClickListener(){
		public void onClick(View arg0) {
			SharedPreferences.Editor editor = prefs.edit();
            editor.putString("friend_name", nameText.getText().toString());
            editor.putString("friend_number", numText.getText().toString());
            editor.putString("first_use", "1");
            editor.commit();
            
            System.out.println("***" + prefs.getString("friend_name", null));
            System.out.println("***" + prefs.getString("friend_number", null));
            
            Intent i = new Intent(EnterDetails.this, MainActivity.class);
			startActivity(i);
	    }}); 
	}
}
